"use strict";
Ajax('/api/list', (data) => {
    renderList(data.data);
});
function renderList(data) {
    const main = document.querySelector('main');
    main.innerHTML = data.map(item => {
        return `
            <dl class='wrap' id='${item.id}'>
                <dt><img src="${item.img}" alt=""></dt>
                <dd>
                    <h3>${item.title}</h3>
                    <p>${item.desc}</p>
                </dd>
            </dl>
        `;
    }).join('');
    bindEvent();
}
function bindEvent() {
    const ItemDom = Array.from(document.querySelectorAll('dl'));
    ItemDom.forEach(item => {
        item.addEventListener('click', () => {
            location.href = `/detail?id=${item.id}&title=123`;
        });
    });
}
